<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用元素属性的值作为 html 进行解析</title>
</head>
<body>
<div id="change" class="change">
    <div html="<h1>Hello, Vue!</h1>" style="background-color: red">Hello, World!</div>
    <div html="<h1>Hello, Vue!</h1>" style="background-color: green">Hello, World!</div>
</div>

<script>
    let elements = document.querySelectorAll("#change > div");
    for (let i = 0; i < elements.length; i++) {
        // console.log(elements[i]);
        // 获取 指定属性的值
        let attribute = elements[i].getAttribute("html");
        console.log(attribute);

        elements[i].innerHTML = attribute;

        // 删除元素指定的属性
        elements[i].removeAttribute("html")
    }
</script>
</body>
</html>